//
//  MLAFundsPayableCell.m
//  MagicLampApp
//
//  Created by Zheng on 2018/12/20.
//  Copyright © 2018 zheng.magic.lamp.app. All rights reserved.
//

#import "MLAFundsPayableCell.h"
#import "MLAFundsPaybleModel.h"

@implementation MLAFundsPayableCell {
    UILabel *titleLbl;
    UILabel *numberLbl;
    UILabel *shopNameLbl;
    UILabel *usernameLbl;
    UILabel *payNumLbl;
    UILabel *startDateLbl;
    UILabel *typeLbl;
}

- (void)setModel:(MLAFundsPaybleModel *)model {
    _model = model;
    
    startDateLbl.text = _model.ctime;
    payNumLbl.text = [NSString stringWithFormat:@"总计：%@元",_model.money];
    usernameLbl.text = [NSString stringWithFormat:@"缴费人：%@",_model.pay_the_fees_name];
    shopNameLbl.text = [NSString stringWithFormat:@"商户名：%@",_model.commercial_tenant_name];
    numberLbl.text = [NSString stringWithFormat:@"商铺号：%@",_model.commercial_tenant_mark];
    titleLbl.text = _model.type_name;

    if (_model.type.integerValue == 1) {
        typeLbl.hidden = NO;
        _payBtn.hidden = YES;
    } else if (_model.type.integerValue == 2) {
        typeLbl.hidden = YES;
        _payBtn.hidden = NO;
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        titleLbl = [[UILabel alloc] init];
        titleLbl.font = CX_GetNormalFont(16);
        titleLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:titleLbl];
        [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.mas_equalTo(19);
        }];
        
        numberLbl = [[UILabel alloc] init];
        numberLbl.font = CX_GetNormalFont(12);
        numberLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:numberLbl];
        [numberLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->titleLbl.mas_bottom).offset(18);
        }];
        
        shopNameLbl = [[UILabel alloc] init];
        shopNameLbl.font = CX_GetNormalFont(12);
        shopNameLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:shopNameLbl];
        [shopNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->numberLbl.mas_bottom).offset(9);
        }];
        
        usernameLbl = [[UILabel alloc] init];
        usernameLbl.font = CX_GetNormalFont(12);
        usernameLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:usernameLbl];
        [usernameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->shopNameLbl.mas_bottom).offset(9);
        }];
        
        payNumLbl = [[UILabel alloc] init];
        payNumLbl.font = CX_GetNormalFont(12);
        payNumLbl.textColor = CX_GetColorBlue();
        [self.shadowView addSubview:payNumLbl];
        [payNumLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->usernameLbl.mas_bottom).offset(20);
        }];
        
        startDateLbl = [[UILabel alloc] init];
        startDateLbl.font = CX_GetNormalFont(10);
        startDateLbl.textColor = CX_GetColorHex(0x999999, 1);
        [self.shadowView addSubview:startDateLbl];
        [startDateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.top.mas_equalTo(24);
        }];
        
        typeLbl = [[UILabel alloc] init];
        typeLbl.font = CX_GetNormalFont(14);
        typeLbl.textColor = CX_GetColorHex(0x6B7178, 1);
        typeLbl.text = @"已支付";
        typeLbl.hidden = YES;
        [self.shadowView addSubview:typeLbl];
        [typeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.bottom.mas_equalTo(-20);
        }];

        
        _payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_payBtn setTitle:@"支付" forState:UIControlStateNormal];
        [_payBtn setTitleColor:CX_GetColorBlue() forState:UIControlStateNormal];
        _payBtn.titleLabel.font = CX_GetNormalFont(14);
        _payBtn.layer.borderColor = CX_GetColorBlue().CGColor;
        _payBtn.layer.borderWidth = 1;
        _payBtn.layer.cornerRadius = 5;
        _payBtn.layer.masksToBounds = YES;
        _payBtn.hidden = YES;
        [self.shadowView addSubview:_payBtn];
        [_payBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.bottom.mas_equalTo(-20);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(30);
        }];
        
        
        /*
         startDateLbl.text = @"2018.9.9 12：21";
         payNumLbl.text = @"总计：4000元";
         usernameLbl.text = @"缴费人：张三";
         shopNameLbl.text = @"商户名：xx有限公司";
         numberLbl.text = @"商铺号：A001";
         titleLbl.text = @"三季度物业费";
         */
    }
    return self;
}


@end
